<?php
session_start();
include ("dbConfig.php");
?>
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js'></script>
<script type="text/javascript" src="js/jquery.airport-1.1.source.js"></script>
<script src="js/main.js" type="text/javascript"></script>
<link href="css/scrolltotop.css" rel="stylesheet" type="text/css">
<link href="css/loginStatus.css" rel="stylesheet" type="text/css">
<title>EduProcrasWebsiteLayout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.centre {
	text-align: center;
	color: #FFF;
}
</style>

<style type="text/css" media="screen">
    
    body{
        background-color: #000;
    }

    /* Give the header a height and a background image */
    #header{
        height:145px; 
        background: #000 url(images/headerbackgroundEX.jpg) repeat-y scroll left top;
        text-align:center;
    }
    
    /* Create a Shadow Overlay */ 
    #header div{
        width:760px;
        height:145px;
        
    }
    
    /* Vertically position header text and style it*/
    #header h1{
        padding-top:40px;
        font-family: BankGothic Lt BT, Geneva, sans-serif;
        color:#000;
		font-size:70px;
    }
    
    /* Give basic styles to the body and the navigation */
    #body{
        background-color:#efefef;
        height:500px;
    }
    #nav{
        height:35px;
        background-color: #111;
    }
	
	p{
		font-family: "BankGothic Lt BT", Geneva;
		font-size: 14px;
		color: white;
	}
	
	p1{
		font-family: "BankGothic Lt BT", Geneva;
		font-size: 18px;
		color: white;
	}
    
</style>

</head>
<body bgcolor="#0000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="centre" onLoad="MM_preloadImages('images/btn_picsOn.gif','images/btn_videoOn.gif','images/btn_aboutOn.gif')">
<a href="#" class="scrollToTop"></a>
<div>
<table id="Table_01" width="1025" height="769" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_01.gif" width="4" height="5" alt=""></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_02.gif" width="187" height="5" alt=""></td>
		<td colspan="9" rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_03.gif" width="833" height="25" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="5" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_04.gif" width="4" height="20" alt=""></td>
		<td rowspan="3"><a href="index.php"><img src="images/img_logo.gif" width="187" height="181" alt="" border="0"></a></td>
		<td>
			<img src="images/spacer.gif" width="1" height="20" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_06.gif" width="4" height="145" alt=""></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_07.gif" width="9" height="145" alt=""></td>
		<td colspan="6">
			<div id="header">
        
        <div>
            <h1>FACTS</h1> 
        </div>  
    </div></td>
		<td colspan="2">
			<img src="images/EduProcrasWebsiteLayout_09.gif" width="64" height="145" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="145" alt=""></td>
	</tr>
	<tr>
		<td rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_10.gif" width="4" height="25" alt=""></td>
		<td colspan="9" rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_11.gif" width="833" height="25" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="16" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_12.gif" width="187" height="9" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="9" alt=""></td>
	</tr>
	<tr>
		<td colspan="4">
		  <img src="images/EduProcrasWebsiteLayout_13.gif" width="70" height="63" alt=""><a href="login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image38','','images/btnLogin_On.jpg',1)"><img src="images/btn_LoginOff.jpg" alt="Login" name="Image38" width="141" height="63" border="0"></a></td>
		<td><a href="pics.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_pics','','images/btn_picsOn.gif',1)"><img src="images/btn_picsOff.gif" alt="Pics" name="btn_pics" width="141" height="63" border="0"></a></td>
		<td><a href="video.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_video','','images/btn_videoOn.gif',1)"><img src="images/btn_videoOff.gif" alt="Videos" name="btn_video" width="141" height="63" border="0"></a></td>
		<td><img src="images/btn_factsOn.gif" width="142" height="63" alt="facts"></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_17.gif" width="3" height="63" alt=""></td>
		<td colspan="2"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_about','','images/btn_aboutOn.gif',1)"><img src="images/btn_aboutOff.gif" alt="About" name="btn_about" width="138" height="63" border="0"></a></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_19.gif" width="57" height="63" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="63" alt=""></td>
	</tr>
	<tr>
		<td colspan="11">
		<div id="loginStatus" style="position: absolute; top: 0; left: 0; width: 500px;">
		<?php
		if ($_SESSION["access"] == 'granted'){?>
            <p1>Logged in. </p1><a href="userLogout.php">
			<p1>Logout</p1></a>
            <?php
			include ("upload.php");
		}
		else{
		?><p1>Not logged in!</p1>
        <?php
		}
		?>
        </div>
        
       	<div id="content" align="center" class="uploadFACT" >
        <br/>
        <br/>
        <br/>
        <br/>
        <p>Be sure to check here regularly for the latest facts!</p>
        <p>Become a member to upload your own content!</p>
        <br/>
        <br/>
        <br/>
        <br/>
        <?php
		
		$sql = "SELECT COUNT(*) FROM 'UPLOADFACTS'";
		
		if ($sth = $dbhandle->query($sql)){
			if ($sth->fetchColumn() > 0){
				$sql = "SELECT link FROM 'UPLOADFACTS' ORDER BY rowid DESC";
				
				foreach ($dbhandle->query($sql) as $row){
					$content = $row['link'];
					?>
                    <br/>
                    <br/>
                    <?php
					$fh = fopen($content, 'r');
					$theData = fgets($fh);
					fclose($fh);
				    ?>
                  //  <div id = 'scroller'>
//                    <script type="text/javascript">
//					document.getElementById('scroller');
//					$(scroller).airport([ '<?php echo $theData ?>' ]);
//					</script>
//                    </div>
                    <p1><?php echo $theData ?><p1>
                    <br/>
                    <br/>
                     <?php
				}
			}
			
			else {
				print "No rows matched the query";
			}
		}
		
		?>
        </div>



        </td>
		<td>
			<img src="images/spacer.gif" width="1" height="510" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/spacer.gif" width="4" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="187" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="9" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="202" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="141" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="141" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="142" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="131" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="7" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="57" height="1" alt=""></td>
		<td></td>
	</tr>
</table>
</div>
</body>


<script type="text/javascript" charset="utf-8">

    var scrollSpeed = 70;       // Speed in milliseconds
    var step = 1;               // How many pixels to move per step
    var current = 0;            // The current pixel row
    var imageHeight = 1500;     // Background image height
    var headerHeight = 145;     // How tall the header is.
    
    //The pixel row where to start a new loop
    var restartPosition = -(imageHeight - headerHeight);
    
    function scrollBg(){
        
        //Go to next pixel row.
        current -= step;
        
        //If at the end of the image, then go to the top.
        if (current == restartPosition){
            current = 0;
        }
        
        //Set the CSS of the header.
        $('#header').css("background-position","0 "+current+"px");
        
        
    }
    
    //Calls the scrolling function repeatedly
    var init = setInterval("scrollBg()", scrollSpeed);
    
</script>   
</html>